import api from '@/http/api.js'

export default{
     namespaced:true,
     state:{
        rows:[],
        pages:0,
        total:0
     },
     mutations:{
            SET_SUB(state,payload){
                Object.assign(state,payload)
            }
     },
     actions:{
       async getSubjectAsync(context,payload){
            const {data}= await api.subject.getSubjects(payload)
                    console.log(data);
            if(data.code){
                 context.commit('SET_SUB',data.data)
            }
         },
         async delSubjectAsync(context,payload){
        
              const {data}=await api.subject.delSubject(payload)
              return data
         },
         async getOneSubjectAsync(context,payload){
              const {data}=await api.subject.getOne(payload)
              return data
         },
         async updataSubjectAsync(context,payload){
              const {data}=await api.subject.updateSubject(payload)
              return data
         },
         async addSubjectAsync(context,payload){
              const {data}=await api.subject.addSubject(payload)
              return data
         }
     }
}